package com.openbravo.data.gui;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.LocalRes;
import com.openbravo.data.loader.Vectorer;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JTextField;

public class JFind extends JDialog
{
  private FindInfo m_FindInfo;
  private Vectorer m_vec;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JButton jcmdCancel;
  private JButton jcmdOK;
  private JTextField m_jFind;
  private JComboBox m_jMatch;
  private JCheckBox m_jMatchCase;
  private JComboBox m_jWhere;

  private JFind(Frame paramFrame, boolean paramBoolean)
  {
    super(paramFrame, paramBoolean);
  }

  private JFind(Dialog paramDialog, boolean paramBoolean)
  {
    super(paramDialog, paramBoolean);
  }

  private FindInfo init(FindInfo paramFindInfo)
    throws BasicException
  {
    initComponents();
    getRootPane().setDefaultButton(this.jcmdOK);
    this.m_jFind.setText(paramFindInfo.getText());
    this.m_jWhere.removeAllItems();
    for (int i = 0; i < paramFindInfo.getVectorer().getHeaders().length; i++)
      this.m_jWhere.addItem(paramFindInfo.getVectorer().getHeaders()[i]);
    this.m_jWhere.setSelectedIndex(paramFindInfo.getField());
    this.m_jMatch.removeAllItems();
    this.m_jMatch.addItem(LocalRes.getIntString("list.startfield"));
    this.m_jMatch.addItem(LocalRes.getIntString("list.wholefield"));
    this.m_jMatch.addItem(LocalRes.getIntString("list.anypart"));
    this.m_jMatch.addItem(LocalRes.getIntString("list.re"));
    this.m_jMatch.setSelectedIndex(paramFindInfo.getMatch());
    this.m_jMatchCase.setSelected(paramFindInfo.isMatchCase());
    this.m_vec = paramFindInfo.getVectorer();
    this.m_FindInfo = null;
    setVisible(true);
    return this.m_FindInfo;
  }

  private static Window getWindow(Component paramComponent)
  {
    if (paramComponent == null)
      return new JFrame();
    if (((paramComponent instanceof Frame)) || ((paramComponent instanceof Dialog)))
      return (Window)paramComponent;
    return getWindow(paramComponent.getParent());
  }

  public static FindInfo showMessage(Component paramComponent, FindInfo paramFindInfo)
    throws BasicException
  {
    Window localWindow = getWindow(paramComponent);
    JFind localJFind;
    if ((localWindow instanceof Frame))
      localJFind = new JFind((Frame)localWindow, true);
    else
      localJFind = new JFind((Dialog)localWindow, true);
    return localJFind.init(paramFindInfo);
  }

  private void initComponents()
  {
    this.jPanel1 = new JPanel();
    this.jLabel1 = new JLabel();
    this.m_jFind = new JTextField();
    this.jLabel2 = new JLabel();
    this.m_jWhere = new JComboBox();
    this.jLabel3 = new JLabel();
    this.m_jMatch = new JComboBox();
    this.m_jMatchCase = new JCheckBox();
    this.jPanel2 = new JPanel();
    this.jcmdOK = new JButton();
    this.jcmdCancel = new JButton();
    setDefaultCloseOperation(2);
    setTitle(LocalRes.getIntString("title.find"));
    setResizable(false);
    this.jPanel1.setLayout(null);
    this.jLabel1.setText(LocalRes.getIntString("label.findwhat"));
    this.jPanel1.add(this.jLabel1);
    this.jLabel1.setBounds(10, 20, 100, 14);
    this.jPanel1.add(this.m_jFind);
    this.m_jFind.setBounds(110, 20, 230, 19);
    this.jLabel2.setText(LocalRes.getIntString("label.where"));
    this.jPanel1.add(this.jLabel2);
    this.jLabel2.setBounds(10, 50, 100, 14);
    this.jPanel1.add(this.m_jWhere);
    this.m_jWhere.setBounds(110, 50, 230, 22);
    this.jLabel3.setText(LocalRes.getIntString("label.match"));
    this.jPanel1.add(this.jLabel3);
    this.jLabel3.setBounds(10, 80, 100, 14);
    this.jPanel1.add(this.m_jMatch);
    this.m_jMatch.setBounds(110, 80, 230, 22);
    this.m_jMatchCase.setText(LocalRes.getIntString("label.casesensitive"));
    this.jPanel1.add(this.m_jMatchCase);
    this.m_jMatchCase.setBounds(110, 110, 230, 20);
    getContentPane().add(this.jPanel1, "Center");
    this.jPanel2.setLayout(new FlowLayout(2));
    this.jcmdOK.setText(LocalRes.getIntString("button.ok"));
    this.jcmdOK.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JFind.this.jcmdOKActionPerformed(paramActionEvent);
      }
    });
    this.jPanel2.add(this.jcmdOK);
    this.jcmdCancel.setText(LocalRes.getIntString("button.cancel"));
    this.jcmdCancel.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        JFind.this.jcmdCancelActionPerformed(paramActionEvent);
      }
    });
    this.jPanel2.add(this.jcmdCancel);
    getContentPane().add(this.jPanel2, "South");
    Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((localDimension.width - 434) / 2, (localDimension.height - 222) / 2, 434, 222);
  }

  private void jcmdCancelActionPerformed(ActionEvent paramActionEvent)
  {
    dispose();
  }

  private void jcmdOKActionPerformed(ActionEvent paramActionEvent)
  {
    this.m_FindInfo = new FindInfo(this.m_vec, this.m_jFind.getText(), this.m_jWhere.getSelectedIndex(), this.m_jMatchCase.isSelected(), this.m_jMatch.getSelectedIndex());
    dispose();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.gui.JFind
 * JD-Core Version:    0.6.0
 */